package com.jinzecloud.fiction.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jinzecloud.fiction.bean.TbBookName;
import com.jinzecloud.fiction.service.TbBookNameService;
import com.jinzecloud.fiction.utils.PageUtils;
import com.jinzecloud.fiction.utils.R;
import org.springframework.web.multipart.MultipartFile;


/**
 * 小说表
 *
 * @author ??
 * @email 1971240051@qq.com
 * @date 2023-10-19 19:38:04
 */
@RestController
@RequestMapping("fiction/tbbookname")
public class TbBookNameController {
    @Autowired
    private TbBookNameService tbBookNameService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("fiction:tbbookname:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbBookNameService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bnId}")
    //@RequiresPermissions("fiction:tbbookname:info")
    public R info(@PathVariable("bnId") Integer bnId){
		TbBookName tbBookName = tbBookNameService.getById(bnId);

        return R.ok().put("tbBookName", tbBookName);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("fiction:tbbookname:save")
    public R save(@RequestBody TbBookName tbBookName){
		tbBookNameService.save(tbBookName);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("fiction:tbbookname:update")
    public R update(@RequestBody TbBookName tbBookName){
		tbBookNameService.updateById(tbBookName);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("fiction:tbbookname:delete")
    public R delete(@RequestBody Integer[] bnIds){
		tbBookNameService.removeByIds(Arrays.asList(bnIds));

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/uploadFile")
    //@RequiresPermissions("fiction:tbbookname:delete")
    public R uploadFile(MultipartFile file){//@RequestBody TbBookName tbBookName,
        String msg = tbBookNameService.saveTbBookName(file);//tbBookName,

        return R.ok().put("data",msg);
    }

}
